<?php
namespace app\api\controller;
use think\Controller;
use think\Db;
use lib\UserCrypt;
class Users extends Base{
    public function userInfo()
    {
    	if(!empty(input("param.token"))){
            $token=input("param.token");
        }else{
            return json(['code' => 501, 'msg' => '令牌呢？']);
        }
        $uid=UserCrypt::do_mdecrypt($token);
        $users=Db::name('users')->field('id,invite_id,phone,money,sex,invite_code')->where('id',$uid)->find();
        if($users){
            $in_money=Db::name('money_bill')->where('user_id',$uid)->where('type',1)->sum('money');
            $out_money=Db::name('money_bill')->where('user_id',$uid)->where('type',2)->sum('money');
            $withdraw_money=Db::name('money_bill')->where('user_id',$uid)->where('type',3)->sum('money');
            return json(['code' => 200, 'msg' => '查询成功' ,'data' =>$users,'in_money' =>$in_money,'out_money' =>$out_money,'withdraw_money' =>$withdraw_money]);
        }else{
            return json(['code' => 500, 'msg' => '查无结果']);
        }
    }
}